package com.hunlian.makelove;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.hunlian.makelove.activity.LoginRegisterActivity;
import com.hunlian.makelove.activity.OrganizingDataActivity;
import com.hunlian.makelove.view.CustomProgressDialog;
import com.umeng.analytics.MobclickAgent;

public class BaseFragemt extends Fragment {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	protected CustomProgressDialog progressDialog = null;
	
	protected void createProgressDialog(Context context){
		if (context == null) return;
		if (progressDialog == null) {
			progressDialog = CustomProgressDialog.createDialog(context, getResources().getString(R.string.loading));
			progressDialog.setOnDismissListener(new OnDismissListener() {
				@Override
				public void onDismiss(DialogInterface dialog) {
					//若是网络请求，则取消请求——但不能全部取消，防止多线程异步请求被取消

				}
			});
		}
		if (!progressDialog.isShowing())
			progressDialog.show();
	}

	/**
	 *跳转到注册
	 *@author zealjiang
	 *@time 2016/5/23 12:49
	 */
	public void skipToRegisterActivity(Activity activity){
		Intent intent = new Intent(activity,LoginRegisterActivity.class);//CheckIsRegisterActivity
		intent.putExtra("from", "register");
		startActivity(intent);
		activity.finish();
	}

	/**
	 *跳转到注册
	 *@author zealjiang
	 *@time 2016/5/23 12:49
	 */
	public void skipToOrganizingDataActivity(Activity activity){
		startActivity(new Intent(activity, OrganizingDataActivity.class));
		activity.finish();
	}

	@Override
	public void onResume() {
		super.onResume();
		MobclickAgent.onResume(this.getContext());
	}

	@Override
	public void onPause() {
		super.onPause();
		MobclickAgent.onPause(this.getContext());
	}
}
